Follow the steps below to link multilanguage programs. (Refer to Figure 2-1 for an illustration of the process.)
For example, if the source consists of a Fortran main program (main.f) and two files of C functions (more.c and rest.c), use the commands:
cc -c more.c rest.c
f77 -c main.f
These commands produce the object files main.o, more.o, and rest.o.
f77 main.o more.o rest.o
The compiler drivers supply the default set of libraries necessary to produce an executable from the source of the associated language. However, when producing executables from source code in several languages, you may need to specify the default libraries explicitly for one or more of the languages used. For instructions on specifying libraries, see "Linking Libraries."
Figure 2-1 : Compilation Control Flow for Multilanguage Programs
Note: Use caution when passing pointers and longs between languages as some languages use different type sizes and structures for data types. For specific details about compiling multilanguage programs, refer to the programming guides for the appropriate languages.